package edu.whcp.comp2301.dao.impl;

import edu.whcp.comp2301.dao.CategoryDao;
import edu.whcp.comp2301.mapper.CategoryMapper;
import edu.whcp.comp2301.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryDaoImpl implements CategoryDao {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> getAllCategories() {
        return categoryMapper.getAllCategories();
    }

    @Override
    public void addCategory(Category category) {
        categoryMapper.addCategory(category);
    }

    @Override
    public Category getCategoryById(String id) {
        return categoryMapper.getCategoryById(id);
    }

    @Override
    public void editCategory(Category category) {
        categoryMapper.editCategory(category);
    }

    @Override
    public void delCategoryById(String id) {
        categoryMapper.delCategoryById(id);
    }

    @Override
    public int queryNewsNumByCategoryId(String id) {
        return categoryMapper.queryNewsNumByCategoryId(id);
    }

}
